@extends('admin::layouts.master')
@section('title')
    活动列表
@endsection
@section('tab')
    <style>
        .phono_ine{
            background: #ccc;
        }
    </style>

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <form class="layui-form layui-col-space5">
                    <div class="layui-input-inline layui-show-xs-block">
                        <select name="type">
                            <option value="1" @if($arr_search['type']==1) selected @endif>维修店</option>
                            <option value="2" @if($arr_search['type']==2) selected @endif>检测站</option>
                        </select>
                    </div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                <i class="layui-icon">&#xe615;</i>
                            </button>
                            <a class="layui-btn layui-btn-small" onclick="location.reload()" title="刷新">
                                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                            </a>
                        </div>
                    </form>
                    <div class="layui-card-body">
                        <button class="layui-btn" onclick="xadmin.open('添加服务类型','{{route("admin_server_type_create")}}' , 550 , 300 )">
                            <i class="layui-icon"></i>添加</button>
                    </div>
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key=>$value)
                                <tr class="phono_ine">
                                    <td>{{ $value['id'] }}</td>
                                    @if( $value['pid'] == 0)
                                        <td> <i class="layui-icon x-show" data-id="{{$value['id']}}" status="true" >&#xe623;</i>{{$value['name']}}</td>
                                        <td>
                                            <a title="添加子级" class="layui-btn layui-btn-warm" onclick="xadmin.open('添加子类','{{route("admin_server_type_create",["pid"=>$value["id"] , "type"=>$value["type"]])}}' , 550 , 300)" href="javascript:;">
                                                添加子级
                                            </a>
                                            <a title="编辑" class="layui-btn" onclick="xadmin.open('编辑','{{route("admin_server_type_edit",["id"=>$value["id"] ])}}' , 550 , 300)" href="javascript:;">
                                                编辑
                                            </a>

                                            <a title="删除" class="ajax_member_del layui-btn layui-btn-danger" data-href="{{route('admin_server_type_delete',['id'=>$value['id']])}}" data-title="确定删除吗？请谨慎操作" href="javascript:;">
                                                删除
                                            </a>
                                        </td>
                                        @foreach( $value['shop_server_type'] as $item)
                                            <tr class="child_{{$value['id']}}" hidden >
                                                <td></td>
                                                <td> {{$item['name']}}</td>
                                                <td>
                                                    <a title="编辑" class="layui-btn" onclick="xadmin.open('编辑','{{route("admin_server_type_edit",["id"=>$item["id"] ])}}' , 550 , 300 )" href="javascript:;">
                                                        编辑
                                                    </a>
                                                    <a title="删除" class="ajax_member_del layui-btn layui-btn-danger" data-href="{{route('admin_server_type_delete',['id'=>$item['id']])}}" data-title="确定删除吗？请谨慎操作" href="javascript:;">
                                                        删除
                                                    </a>
                                                </td>
                                            </tr>
                                        @endforeach
                                    @endif
                                </tr>
                            @endforeach
                            @if(empty($data))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            $("body").on('click','.x-show',function(){
                var id = $(this).attr('data-id');
                if( $(this).attr('status') == 'true'){
                    $(this).html('&#xe625;');
                    $(this).attr('status','false');
                    $(".child_"+id).show();
                }else{
                    $(this).html('&#xe623;');
                    $(this).attr('status','true');
                    $(".child_"+id).hide();
                }
            })

        })
    </script>
@endsection




